#include<iostream>
#include<vector>
using namespace std;
int main()
{
    int n;
    int m;
    cin>>n>>m;
    vector<long long> nums(n+1);
    vector<long long> dp(n+1);
    for(int i=1;i<=n;++i)
        cin>>nums[i];
    for(int i=1;i<=n;++i)
        dp[i]=dp[i-1]+nums[i];
    while(m--)
    {
        int l,r;
        cin>>l>>r;
        long long sum=dp[r]-dp[l-1];
        cout<<sum<<endl;
    }
    return 0;
}
